package cn.ljh.student.service.impl;
import cn.ljh.student.dao.ScoreMapper;
import cn.ljh.student.pojo.Score;
import cn.ljh.student.service.ScoreService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class ScoreServiceImpl implements ScoreService {

    @Resource
    private ScoreMapper scoreMapper;

    public Score getScoreById(String id)throws Exception{
        return scoreMapper.getScoreById(id);
    }

    public List<Score>	getScoreListByMap(Map<String,Object> param)throws Exception{
        return scoreMapper.getScoreListByMap(param);
    }

    public Integer getScoreCountByMap(Map<String,Object> param)throws Exception{
        return scoreMapper.getScoreCountByMap(param);
    }

    public Integer qdtxAddScore(Score score)throws Exception{
            //score.setCreatedTime(new Date());
            return scoreMapper.insertScore(score);
    }

    public Integer qdtxModifyScore(Score score)throws Exception{
        //score.setUpdatedTime(new Date());
        return scoreMapper.updateScore(score);
    }

    public Integer qdtxDeleteScoreById(String id)throws Exception{
        return scoreMapper.deleteScoreById(id);
    }

    public Integer qdtxBatchDeleteScore(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return scoreMapper.batchDeleteScore(param);
    }


}
